<?php

namespace app\admin\controller;

class Push extends Member
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 发布系统消息
     * @param string $str_client 客户端名称 多个用,隔开
     * @param string $str_title 标题
     * @param string $str_desc 推送标题(描述)
     * @param int $int_release_status 发布状态 0-暂不发布 1-立即发布 2-预约发布
     * @param string $str_release_time 预约的发布时间
     * @param string $str_push_type 推送类型 text-图文 url-地址跳转
     * @param string $str_content 内容(push_type值对应该字段的值)
     * @param string $str_url 跳转地址
     * @param string $str_remark 备注
     */
    public function releaseSystemMessage()
    {
        $str_client = $this->_getContentParams('client');
        $str_title = $this->_getContentParams('title');
        $str_desc = $this->_getContentParams('desc');
        $int_release_status = $this->_getContentParams('releaseStatus');
        $str_subscribe_time = $this->_getContentParams('subscribeTime');
        $int_is_push = intval($this->_getContentParams('isPush', -1));
        $str_push_type = $this->_getContentParams('pushType');
        $str_content = $this->_getContentParams('content');
        $str_url = $this->_getContentParams('url');
        $str_remark = $this->_getContentParams('remark');

        $obj = new \app\logic\push\AdminPush();
        $obj->releaseSystemMessage($str_client, $str_title, $str_desc, $int_release_status, $str_subscribe_time, $int_is_push, $str_push_type, $str_content, $str_url, $str_remark, $this->admin_id);
    }

    /**
     * 消息推送（多人）（发布活动消息）
     * @param string $str_map_id 用户编号 多个用,隔开
     * @param string $str_client 客户端名称
     * @param string $str_title 标题
     * @param string $str_desc 推送标题(描述)
     * @param int $int_release_status 发布状态 0-暂不发布 1-立即发布 2-预约发布
     * @param string $str_subscribe_time 预约时间
     * @param string $str_push_type 推送类型 text-图文 url-地址跳转
     * @param string $str_content 内容(push_type值对应该字段的值)
     * @param string $str_url 跳转地址
     * @param string $str_platform 平台名称 all-所有 android-安卓 ios-苹果
     */
    public function releaseActivityMessage()
    {
        $str_map_id = $this->_getContentParams('mapId');
        $str_client = $this->_getContentParams('client');
        $str_title = $this->_getContentParams('title');
        $str_desc = $this->_getContentParams('desc');
        $int_release_status = $this->_getContentParams('releaseStatus');
        $str_subscribe_time = $this->_getContentParams('subscribeTime');
        $int_is_push = intval($this->_getContentParams('isPush', -1));
        $str_push_type = $this->_getContentParams('pushType');
        $str_content = $this->_getContentParams('content');
        $str_url = $this->_getContentParams('url');
        $str_platform = $this->_getContentParams('platform');

        $obj = new \app\logic\push\AdminPush();
        $obj->releaseActivityMessage($str_map_id, $str_client, $str_title, $str_desc, $int_release_status, $str_subscribe_time, $int_is_push, $str_push_type, $str_content, $str_url, $str_platform, $this->admin_id);
    }

    /**
     * 获取所有客户端
     */
    public function getAllClient()
    {
        $obj = new \app\logic\push\AdminPush();
        $obj->getAllClient();
    }

    /**
     * 获取系统消息列表
     */
    public function getSystemMessageList()
    {
        $int_page = intval($this->_getContentParams('page'));
        $int_list_rows = intval($this->_getContentParams('listRows'));
        $obj = new \app\logic\push\AdminPush();
        $obj->getSystemMessageList($int_page, $int_list_rows);
    }

    /**
     * 获取活动消息列表
     */
    public function getActivityMessageList()
    {
        $int_page = intval($this->_getContentParams('page'));
        $int_list_rows = intval($this->_getContentParams('listRows'));

        $obj = new \app\logic\push\AdminPush();
        $obj->getActivityMessageList($int_page, $int_list_rows);
    }

    /**
     * 获取用户消息列表
     * URI:/admin/get.user.message.list
     */
    public function getUserMessageList()
    {
        $int_page = intval($this->_getContentParams('page'));
        $int_list_rows = intval($this->_getContentParams('listRows'));
        $int_user_id = intval($this->_getContentParams('userId', 0));

        $obj = new \app\logic\push\AdminPush();
        $obj->getUserMessageList($int_page, $int_list_rows, $int_user_id);
    }

    /**
     * 获取用户消息详情
     * URI:/admin/get.user.message.info
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getUserMessageInfo()
    {
        $int_message_id = intval($this->_getContentParams('messageId'));
        _toValidate('id', $int_message_id, 10114);
        $int_user_id = intval($this->_getContentParams('userId', 0));

        $obj = new \app\logic\push\AdminPush();
        $obj->getUserMessageInfo($int_message_id, $int_user_id);
    }

    /**
     * 获取系统消息详情
     * URI:/admin/get.system.message.info
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getSystemMessageInfo()
    {
        $int_message_id = intval($this->_getContentParams('messageId'));
        _toValidate('id', $int_message_id, 10114);

        $obj = new \app\logic\push\AdminPush();
        $obj->getSystemMessageInfo($int_message_id);
    }

    /**
     * 获取系统消息详情
     * URI:/admin/get.system.message.info
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getActivityMessageInfo()
    {
        $int_message_id = intval($this->_getContentParams('messageId'));
        _toValidate('id', $int_message_id, 10114);

        $obj = new \app\logic\push\AdminPush();
        $obj->getActivityMessageInfo($int_message_id);
    }


    /**
     * 获取活动消息列表
     */
    public function deleteSystemMessage()
    {

    }
}
